package com.mofang.adapters;

import java.util.List;
import java.util.Map;

import com.mofang.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class HouseSourceDetailAdapter extends BaseAdapter {
	Context c;
	List<Map<String, Object>> list;
	private LayoutInflater inflater;

	public HouseSourceDetailAdapter(Context context,
			List<Map<String, Object>> list) {
		// TODO Auto-generated constructor stub
		inflater = LayoutInflater.from(context);
		this.c = context;
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		// TODO Auto-generated method stub
		Holder myHolder;
		if (convertView == null) {
			myHolder = new Holder();
			convertView = inflater.inflate(R.layout.house_source_detail_item,
					null);

			myHolder.hourse_bitmap = (ImageView) convertView
					.findViewById(R.id.hourse_bitmap);
			myHolder.introduct = (TextView) convertView
					.findViewById(R.id.introduct);

			convertView.setTag(myHolder);
		} else {
			myHolder = (Holder) convertView.getTag();
		}
		myHolder.hourse_bitmap.setImageResource((Integer) (list.get(position)
				.get("drawable")));

		myHolder.introduct.setText(list.get(position).get("data").toString());
		return convertView;

	}

	class Holder {
		ImageView hourse_bitmap;
		TextView introduct;
	}

}
